var t = require("../../../@babel/runtime/helpers/objectWithoutProperties"), a = [ "url" ], n = getApp();

Page({
    data: {
        keyword: "",
        total_page: 0,
        page: 1,
        list: [],
        loading: !1,
        finished: !1
    },
    onLoad: function(t) {},
    getData: function() {
        var t = this;
        if (!this.data.loading && !this.data.finished) {
            this.data.loading = !0;
            var a = n.getNetAddresss("plugin.warehouse.frontend.controllers.gift.list");
            n._postNetWork({
                url: a,
                data: {
                    keyword: this.data.keyword,
                    page: this.data.page
                },
                success: function(a) {
                    var n = a.data;
                    t.data.loading = !1, 1 == n.result ? (t.setData({
                        list: t.data.list.concat(n.data.data)
                    }), t.data.page = t.data.page + 1, n.data.current_page == n.data.last_page && (t.data.finished = !0)) : wx.showToast({
                        icon: "none",
                        title: n.msg,
                        duration: 1e3
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    initData: function() {
        this.data.loading = !1, this.data.finished = !1, this.data.page = 1, this.data.list = [];
    },
    onChange: function(t) {
        this.setData({
            keyword: t.detail
        });
    },
    onSearch: function() {
        this.initData(), this.getData();
    },
    toUrl: function(t) {
        var a = t.currentTarget.dataset || {};
        this.wxRouterLink(a);
    },
    wxRouterLink: function(n) {
        var i = "", e = n.url, o = t(n, a);
        Object.keys(o).forEach(function(t) {
            "" !== o[t] && (i += t + "=" + o[t] + "&");
        }), "" !== e && wx.navigateTo({
            url: e + "?" + i.slice(0, -1)
        });
    },
    onReady: function() {},
    onShow: function() {
        this.getData();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.getData();
    },
    onShareAppMessage: function() {}
});